#ifndef _IDIS_SW_SCHEDULER_H
#define _IDIS_SW_SCHEDULER_H
////////////////////////////////////////////////////////////////

#include "Type.h"

namespace Idis {

struct ScheduleItem {
    bool enable;
    int32 channel;
    uint32 resolution;
    uint32 interval;
    uint32 maxInterval;
    uint32 increment;
    uint32 penalty;
    uint32 timeAfterSchedule;
    uint32 waitingCount;
    uint32 captureCount;
    bool requestedKeyFrame;
};

class SwScheduler {
public:
    SwScheduler();
    virtual ~SwScheduler() {}

public:
    void init(int32 videoType);
    void clear();
    void applySituation(int32 channel, uint32 resolution, float ips, bool enable, bool keyFrame);
    void simulate();

public:
    static const uint32 BIT_COUNT;
    static const uint32 MAX_PENALTY;
    static const uint32 MAX_WAITING_COUNT;

protected:
    bool canBeScheduled(int32 imageCount, const ScheduleItem& info);
    void capturedImage(ScheduleItem& info, uint32 fieldCount);

public:
    float estimatedIps(int32 channel) const { return (float)_estimatedIps[channel]; }
    const ScheduleItem& scheduleInfo(int32 channel) const { return _scheduleList[channel]; }

private:
    bool _ntsc;
    uint32 _imagePerField;
    uint32 _fieldCountForSecond;
    ScheduleItem _scheduleList[MCP_CODEC_SLOT_COUNT + 1];
    uint32 _estimatedIps[MCP_CODEC_SLOT_COUNT + 1];
};


} // end of Idis

////////////////////////////////////////////////////////////////
#endif // _IDIS_SW_SCHEDULER_H


// <EOF>

